//
//  ViewController.swift
//  Swift网络请求封装
//
//  Created by HM on 16/9/20.
//  Copyright © 2016年 HM. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        print("准备")
         loadData()
       
    }
    
    func loadData()  {
        
        
        
        //  准备url接口地址
        let url = "http://192.168.0.141:8080/loginStuUser"
        //  准备参数
        let params: [String: Any] = ["login_name": "baihaitao", "login_pwd": "123456"]
        print(params)
        

        HMNetworkTools.sharedTools.request(type: .POST, url: url, params:params
        ) { (response, error) in
            
            if error != nil {
                
                print("网络请求异常: \(error!)")
                return
            }
            
            //  代码执行到此,表示网络请求成功
            if let result = response {
                print(result)
                
            }
            
            
        }
        
        
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

